<%@ page import="java.sql.DriverManager" %>

<%@ page import="java.sql.Connection" %>

<%@ page import="java.sql.Statement" %>

<%@ page import="bean.UserBean" %>
<%--
  Created by IntelliJ IDEA.
  User: 113
  Date: 2020/10/2
  Time: 10:40
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%
        UserBean user = new UserBean();
        user.setUsername(request.getParameter("username"));

        user.setPassword(request.getParameter("password"));
        Class.forName("com.mysql.jdbc.Driver");
        String url = "jdbc:mysql://localhost:3306/book";
        Connection connection = DriverManager.getConnection(url,"root","root");



        Statement stmt = connection.createStatement();

String sql="insert into user(username,password,gender,age)values('"+user.getUsername()+"','"+user.getPassword()+"',1,22)";

//String sql="update user set status=3 where id=10";
       // String sql = "delete from user where id = 3";






        int count = stmt.executeUpdate(sql); //如果报此行有错误 数码上一行的sql语句是有问题的 请检查数据库



        if(count == 0 ){

            out.print("更新失败");
        }else {

                out.print("更新成功");
        }  %>